"""
FileName：user_multi_manager.py
Description：
Author：gaojiahui
Time：2025/8/14 23:37
Website：https://gitee.com/gao-jiahui
"""
from day02_token.smart_auth_manager import SmartAuthManager

"""实现多用户管理"""
class MultiUserManager:
    def __init__(self):
        self.users = {}   # {username:auth_manager}

    def add_user(self,username,password):
        """添加新用户会话"""
        mgr = SmartAuthManager("http://pig-gateway:9999")
        if mgr.login(username,password):
            self.users[username] = mgr      # 存储用户管理器

    def switch_user(self,username):
        """切换当前用户"""
        return self.users.get(username)